Micron Document
Gopher Proxy


gopherpedia.com:70 gopherpedia.com:70/0//env
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

======================================================================
= env =
======================================================================

Introduction
======================================================================
env is a shell command that either reports environment variables or
runs a command in a subprocess with modified environment variables.
The command is provided in a Unix-like system.

By default, a subprocess inherits the environment variables of the
parent process. env supports adding, modifying and removing the copied
variables. env can also be used to launch the correct interpreter. In
this usage, the environment is typically not changed. The command does
not modify environment variables in the process in which it runs.
Mechanisms for doing so include the command and assigning a name to a
value like .

The GNU coreutils version was written by Richard Mlynarik, David
MacKenzie, and Assaf Gordon. It first appeared in 4.4BSD, and is a
part of POSIX.1 (with the option only). This version has been
extended to handle signals and the current directory.

FreeBSD's version supports a custom search path. Extensions found in
both versions include , for unsetting variables, and , for splitting
arguments (mainly in shebang).


Examples
======================================================================
The following command line prints the current environment variables to
standard output:

$ env


The following command line creates a new shell without any environment
variables:

$ env -i /bin/sh


The following command line executes the application xcalc such that
the variable DISPLAY has value "foo.bar:1.0" so that it shows on the
specified display:

$ env DISPLAY=foo.bar:1.0 xcalc


This use of env is often unnecessary since most shells support setting
environment variables in front of a command like:

$ DISPLAY=foo.bar:1.0 xcalc


env may also be used in the hashbang line of a script to allow the
interpreter to be looked up via the PATH. For example, here is the
code of a Python script:

#!/usr/bin/env python3
print("Hello, World!")


In this example, /usr/bin/env is the full path of the env command. The
environment is not altered.

Note that it is possible to specify the interpreter without using env,
by giving the full path of the python interpreter. A problem with that
approach is that on different computer systems, the exact path may be
different. By instead using env as in the example, the interpreter is
searched for and located at the time the script is run (more
precisely, env does a system call to execvp, which does the job of
locating the interpreter and launching it). This makes the script more
portable, but also increases the risk that the wrong interpreter is
selected because it searches for a match in every directory on the
executable search path. It also suffers from the same problem in that
the path to the env binary may also be different on a per-machine
basis.


See also
======================================================================
* List of POSIX commands
* set


External links
======================================================================
*
*
*
[https://www.gnu.org/software/coreutils/manual/html_node/env-invocation.html
env]--manual page from GNU coreutils.
*
*
*
*
*


License
=========
All content on Gopherpedia comes from Wikipedia, and is licensed under CC-BY-SA
License URL: http://creativecommons.org/licenses/by-sa/3.0/
Original Article: http://en.wikipedia.org/wiki/env


.

you're on gopherpedia.com^70/0//env
back link is gopherpedia.com:70/1/